#include<stdio.h>
#include<malloc.h>
#define PEOPLE struct people
#define LEN sizeof(PEOPLE)

PEOPLE{
	char *name;
	int age;
	PEOPLE *next;
};

PEOPLE *create(int n){
	PEOPLE *head,*pf,*pb;
	int i;
	printf("input data\n");

	for(i = 0; i < n; i++){
		pb = (PEOPLE *)malloc(LEN);
		scanf("%d%s",&pb->age,pb->name);
		if(i == 0){
			pf = head = pb;
		}else{
			pf->next = pb;
		}
		pb->next = 0;
		pf = pb;
	}
	return head;
}

void main(){
	PEOPLE *p = create(3);
	int i;
	for(i = 0; i < 3; i++,p=p->next){
		printf("%s %d\n",p->name,p->age);
	}
}